package com.ningju.procurement.core.questionnaire.service;

import com.ningju.procurement.common.service.BaseServiceImpl;
import com.ningju.procurement.core.questionnaire.bean.Answer;
import com.ningju.procurement.core.questionnaire.bean.Topic;
import com.ningju.procurement.core.questionnaire.dao.AnswerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

/**
 * 题目答案信息
 */
@Service
public class AnswerService extends BaseServiceImpl<AnswerDao, Answer> {

    @Autowired
    private AnswerDao answerDao;

    @Transactional
    public boolean save(Answer answer) {

        Assert.notNull(answer);

        return super.save(answerDao, answer);
    }

    public boolean destoryByTopic(Topic topic) {

        Assert.notNull(topic);

        return answerDao.deleteByTopic(topic) > 0;
    }

}
